cuenta atras segundero python

37

import time

def countdown(num_of_secs):
    while num_of_secs:
        m, s = divmod(num_of_secs, 60)
        min_sec_format = '{:02d}:{:02d}'.format(m, s)
        print(min_sec_format, end='/r')
        time.sleep(1)
        num_of_secs -= 1
        
    print('Countdown finished.')

inp = input('Input number of seconds to countdown: ')
countdown(inp)

Comments

Submit
0 Comments